/**
 * Created by victor on 2016/8/23.
 */
import { getCurrentUser } from './vuex/getters'
export function RouteConfig (router){
  // normal routes
  router.map({
    '*':{
      component:require('./components/not-found.vue')
    },
    '':{
      component:require('./components/bg.vue')
    },

    '/main':{
        component:require('./components/Main.vue'),
        subRoutes:{
          '/home':{
            component:require('./components/Home.vue'),
          },
          '/waterfall':{
            component:require('./components/Waterfall.vue'),
          }
        }
      },
    '/Login':{
        component:require('./components/Login.vue'),
      },
    '/Login_in':{
        component:require('./components/Login_in.vue')
    }

  })

  // redirect
  router.redirect({
    '/info': '/about',
    '/hello/:userId': '/user/:userId',
    '/hello': '/user',
    '/hello/:userId/posts': '/user/:userId/posts',
  })

  // global before
  // 3 options:
  // 1. return a boolean
  // 2. return a Promise that resolves to a boolean
  // 3. call transition.next() or transition.abort()
  //可以在全局的beforeEach中配置,也可以在单个vue中的route中的hook配置,根据路径的区分,特殊的设置一些选项.
  router.beforeEach((transition) => {
    transition.next()
  })
}
